package com.xtayfjpk.mbassador.test.listener;

import java.io.File;
import java.util.HashMap;
import java.util.LinkedList;

import net.engio.mbassy.listener.Enveloped;
import net.engio.mbassy.listener.Handler;
import net.engio.mbassy.listener.Invoke;
import net.engio.mbassy.listener.Listener;
import net.engio.mbassy.listener.References;
import net.engio.mbassy.subscription.MessageEnvelope;

@Listener(references=References.Strong)
public class SimpleFileListener {

	@Handler
	public void handle(File file) {
		// do something with the file
		System.out.println("handle file:" + file);
	}
	
	@Handler(delivery = Invoke.Asynchronously)
    public void expensiveOperation(File file){
		System.out.println("expensive operation file:" + file);
    }
    
    @Handler(condition = "msg.size >= 0")
    @Enveloped(messages = {HashMap.class, LinkedList.class})
    public void handleLarge(MessageEnvelope envelope) {
    	System.out.println("handle large file:" + envelope);
    }
}
